$(function(){
    $(".NoPassword").mouseover(function(){
        $(this).css("color","#ff8a00").css("borderBottom","2px solid #ff8a00").siblings().css("color","#808080").css("borderBottom","0")
        $(".xxk1").hide()
        $(".xxk2").show()
        $(".login-img img").css("img","./images/login2.png")
    })
    $(".Direct-login").mouseover(function(){
        $(this).css("color","#ff8a00").css("borderBottom","2px solid #ff8a00").siblings().css("color","#808080").css("borderBottom","0")
        $(".xxk2").hide()
        $(".xxk1").show()
    })
    //初始化表单验证插件
    let obj =$('#myform').validate({
        rules: {//创建的规则
            username: {
                required: true,
                isName:true,
            },
            password: {
                required: true,
                isPwd: true
            },
        },
        messages: {//错误的提示信息
            username: {
                required: '请输入用户名',
                minlength: '请输入最少六位字符'
            },
            password: {
                required: "输入密码了没",
            }
        }
    });
    $(".login-btn").click(function(){
        let bool =obj.form()
        if(bool){
            location.href="./index.html";
        }
    })

    jQuery.validator.addMethod(
        "isName",
        function (value, element) {
            var tel = /^[a-zA-Z0-9_-]{6,12}$/;
            return this.optional(element) || (tel.test(value));
        }, "请正确输入用户名");
    jQuery.validator.addMethod(
        "isPwd",
        function (value, element) {
            var tel = /^[a-zA-Z0-9_-]{8,16}$/;
            return this.optional(element) || (tel.test(value));
        }, "请正确输入密码");
})